package com.example.myapplication;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import androidx.fragment.app.Fragment;

public class zzzzz2025103101MustBuyFragment extends Fragment {
    private View view;
    private String[] names = {"招牌烤鸭套餐", "经典牛肉面", "特色小笼包"};
    private String[] sales = {"月售320 好评度95%", "月售210 好评度92%", "月售189 好评度88%"};
    private String[] prices = {"￥38", "￥18", "￥15"};
    private int[] imgs = {R.drawable.z2025103101_must_buy_one, R.drawable.z2025103101_must_buy_two, R.drawable.z2025103101_must_buy_three};

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.zzzzz2025103101frag_layout, container, false);
        ListView listView = view.findViewById(R.id.zzzzz2025103101lv_list);
        MyBaseAdapter adapter = new MyBaseAdapter();
        listView.setAdapter(adapter);
        return view;
    }

    class MyBaseAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return names.length;
        }

        @Override
        public Object getItem(int i) {
            return names[i];
        }

        @Override
        public long getItemId(int i) {
            return i;
        }

        @Override
        public View getView(int i, View convertView, ViewGroup viewGroup) {
            View view = View.inflate(getActivity(), R.layout.zzzzz2025103101list_item, null);
            TextView tv_name = view.findViewById(R.id.zzzzz2025103101iv_name);
            TextView tv_sale = view.findViewById(R.id.zzzzz2025103101iv_sale);
            TextView tv_price = view.findViewById(R.id.zzzzz2025103101iv_price);
            ImageView iv = view.findViewById(R.id.zzzzz2025103101iv_img);

            tv_name.setText(names[i]);
            tv_sale.setText(sales[i]);
            tv_price.setText(prices[i]);
            iv.setImageResource(imgs[i]);
            return view;
        }
    }
}
